
var Utils = require('./Utils');
module.exports = function(passport) {
	var exports = {
		getUserInfo: function(req, res, next){
			passport.authenticate('jwt', function(err, user, info) {
		    if (err) { return next(err); }
		    if (!user) { 
		    	res.json(Utils.getReloginObj());
		    }else{
		    	var userInfo = {};
		    	userInfo.name = user.name;
		    	userInfo.username = user.username;
		    	userInfo.email = user.email;
		    	res.json(userInfo);
		    }
		    
		  })(req, res, next);
		}
	};
	return exports;
}
